﻿@using KC.Web.Admin.Constants
@model KC.DTO.Admin.DatabasePoolDTO

@{
    Layout = null;
}

@using (Html.BeginForm(ActionName.DatabasePool.SaveDatabasePoolForm, ControllerName.DatabasePool, FormMethod.Post, new { id = "saveform", @class = "easyui-form" }))
{
    @Html.AntiForgeryToken()
    @Html.HiddenFor(model => model.DatabasePoolId)
    @Html.HiddenFor(model => model.TenantCount)
    @Html.HiddenFor(model => model.CanEdit)
    @Html.HiddenFor(model => model.IsDeleted)
    @Html.HiddenFor(model => model.CreatedBy)
    @Html.HiddenFor(model => model.CreatedDate)
    @Html.HiddenFor(model => model.ModifiedBy)
    @Html.HiddenFor(model => model.ModifiedDate)
    <table class="dialog-form-table">
        <tbody>
            @if (Model.IsEditMode)
            {
                <tr>
                    <td><label class="required">*</label><label for="CloudType">云服务：</label></td>
                    <td>@Html.DropDownListFor(c => c.CloudType, null, new {@id= "CloudType", @class = "easyui-combobox", @style = "width: 200px;height:26px;", @readonly = "readonly" })</td>
                </tr>
            }
            else
            {
                <tr>
                    <td><label class="required">*</label><label for="StoragePoolId">云服务：</label></td>
                    <td>@Html.DropDownListFor(c => c.CloudType, null, new { @class = "easyui-combobox", @style = "width: 200px;height:26px;" })</td>
                </tr>
            }
            <tr>
                <td><label class="required">*</label><label for="DatabaseType">类型：</label></td>
                <td>
                    @Html.DropDownListFor(c => c.DatabaseType, null, new {@id= "DatabaseType", @class = "easyui-combobox", @style = "width: 200px;height:26px;" })
                </td>
            </tr>
            <tr>
                <td><label class="required">*</label><label for="Server">服务器：</label></td>
                <td><input id="Server" name="Server" class="easyui-validatebox textbox" data-options="required:true,width:200" value="@Model.Server" /></td>
            </tr>
            <tr>
                <td><label class="required">*</label><label for="Database">数据库：</label></td>
                <td><input id="Database" name="Database" class="easyui-validatebox textbox" data-options="required:true,width:200" value="@Model.Database" /></td>
            </tr>
            <tr>
                <td><label class="required">*</label><label for="UserName">用户名：</label></td>
                <td><input id="UserName" name="UserName" class="easyui-validatebox textbox" data-options="required:true,width:200" value="@Model.UserName" /></td>
            </tr>
            <tr>
                <td><label class="required">*</label><label for="UserPassword">用户密码：</label></td>
                <td>
                    <input id="UserPassword" name="UserPassword" class="easyui-validatebox textbox" data-options="width:200,validType:'length[3,40]'" value="@Model.UserPassword" />
                </td>
            </tr>
            <tr>
                <td><a id="btnGeneratePwd" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-standard-pencil-go" plain="true" onclick="generatePasswordHash()">生成加密密码</a></td>
                <td><input id="UserPasswordHash" readonly="readonly" name="UserPasswordHash" class="easyui-validatebox textbox" data-options="required:true,width:200,validType:'length[3,500]'" value="@Model.UserPasswordHash" /></td>
            </tr>
            <tr>
                <td><label for="PasswordExpiredTime">密码过期时间：</label></td>
                <td><input id="PasswordExpiredTime" name="PasswordExpiredTime" type="text" class="easyui-datebox textbox" data-options="required:false,width:200,height:26,validType:'date',novalidate:true" value="@Model.PasswordExpiredTime" /></td>
            </tr>
            <tr>
                <td colspan="2"><a id="btnTestConnect" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-standard-package-link" plain="true" onclick="testConnection()">测试连接</a></td>
            </tr>
        </tbody>
    </table>
}

<script type="text/javascript">
    $("#DatabaseType").combobox({
        required: true,
        editable: false
    })
    $("#CloudType").combobox({
        required: true,
        editable: false
    })
</script>